import { baseUrlApi, requestClient, type Result } from '#/api/request';

/** 获取列表 */
export const getModuleField = (params?: object) => {
  return requestClient.get<Result>(
    baseUrlApi('/portal/admin/module_attributes'),
    {
      params,
    },
  );
};

/** 添加 */
export const postModuleField = (data?: object) => {
  return requestClient.post<Result>(
    baseUrlApi('/portal/admin/module_attributes'),
    data,
  );
};

/** 获取信息 */
export const getModuleFieldInfo = (data: { id: number }) => {
  return requestClient.get<Result>(
    baseUrlApi(`/portal/admin/module_attributes/${data.id}`),
  );
};

/** 编辑 */
export const putModuleField = (id: number, data?: any) => {
  return requestClient.put<Result>(
    baseUrlApi(`/portal/admin/module_attributes/${id}`),
    data,
  );
};

/** 删除 */
export const deleteModuleField = (data?: any) => {
  return requestClient.delete<Result>(
    baseUrlApi(`/portal/admin/module_attributes/${data.id}`),
    data,
  );
};

/** 设置状态 */
export const postModuleFieldStatus = (data: { id: number }) => {
  return requestClient.post<Result>(
    baseUrlApi(`/portal/admin/module_attributes/${data.id}/status`),
    data,
  );
};

/** 后台菜单排序 */
export const postModuleFieldListOrder = (data?: { list_orders: object }) => {
  return requestClient.post<Result>(
    baseUrlApi('/portal/admin/module_attributes/list/order'),
    data,
  );
};
